<?php
/**
 * All Bootstrap Classes starting with _init will be called 
 * 
 */

 class Bootstrap extends Yaf_Bootstrap_Abstract{

    # Init Config
    public function _initConfig(Yaf_Dispatcher $dispatcher) {
        $config = Yaf_Application::app()->getConfig();
        Yaf_Registry::set("config",$config);
        //Turn off auto render
        $dispatcher->autoRender(false);
    }


    # Init Common Functions
    public function _initCommonFunctions(){  
        Yaf_Loader::import(Yaf_Application::app()->getConfig()->application->directory . '/common/Functions.php');  
        Yaf_Loader::getInstance()->registerLocalNamespace(array("Foo", "Local"));
    } 

    # Init Plugin
    public function _initPlugin(Yaf_Dispatcher $dispatcher) {
        $router = new RouterPlugin();
        $dispatcher->registerPlugin($router);
    }   

     # Init Router
     public function _initRoute(Yaf_Dispatcher $dispatcher) {  
        $router = $dispatcher->getRouter();
        $config = new Yaf_Config_ini(APP_PATH . '/conf/router.ini', 'routes');
        if ($config->routes) {
//            $router = Yaf_Dispatcher::getInstance()->getRouter();
            $router->addConfig($config->routes);
        }
      }

      # Init Database Config
      public function _initDatabaseInfo(Yaf_Dispatcher $dispatcher){
        $config = new Yaf_Config_ini(APP_PATH . '/conf/database.ini');
        Yaf_Registry::set("dbConfig",$config);
      }
      
 }